import { createApp } from 'vue'
import App from './App.vue'
import routes from './router'
import { createRouter, createWebHistory } from 'vue-router'
import './public-path';

const app = createApp(App)


function render(props = {}) {
  const { container } = props;
  const base = window.__POWERED_BY_QIANKUN__ ? '/app-vue3/' : '/';
  const router = createRouter({
    history: createWebHistory(base),
    routes
  })
  const appEl = container ? container.querySelector('#app') : '#app'
  app.use(router).mount(appEl);
}

console.log("window.__POWERED_BY_QIANKUN__", window.__POWERED_BY_QIANKUN__)

if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

export async function bootstrap() {
  console.log('---- [vue3] bootstrap ----');
}
export async function mount(props) {
  console.log('---- [vue3] mount ----', props);
  render(props);
}
export async function unmount() {
  app.unmount()
}